<template>
  <div class="content">
      <nut-navbar class="navbar" z-index="5" :clickable="false"  fixed safe-area-inset-top>
        <template #content>
          <span>{{ t(String(route.meta.title)) }}</span>
        </template>
        <template #left>
          <img src="/imgs/club/arrow_left.png" alt="" @click="router.go(-1)" class="arrow_left" />
        </template>
        <template #right>
          <span class="save" @click="router.push('/club/member/approvalMenber')">{{t('club_page_cysp')}}</span>
        </template>
      </nut-navbar>



    <Modal v-model:visible="isShowWin" :title="t(club_title)" @close="">
      <div class="popup_body">
        <div class="info">{{ club_tip }}</div>
        <div class="submit_btn">
          <span class="submit_close" @click="close">{{ t('cancel') }}</span>
          <Btn height="44px" width="147px" class="submit" @click="submitAc">{{ t('confirm') }}</Btn>
        </div>
      </div>
    </Modal>
  </div>
</template>

<script setup lang="ts">
import { useI18n } from "vue-i18n";
import { ref, reactive } from "vue";
import {useRoute, useRouter} from "vue-router";

const route = useRoute();
const router = useRouter();
const { t } = useI18n();

// 牌局列表
const members = reactive([
  {
    id: 1,
    name: "Frank002",
    avatar: "/imgs/club/member_avatar.png",
    vipLevel: "/imgs/club/vip.png",
    role: "creator",
  },
  {
    id: 2,
    name: "Frank002",
    avatar: "/imgs/club/member_avatar.png",
    vipLevel: "/imgs/club/vip.png",
    role: "admin",
  },
  {
    id: 3,
    name: "Frank002",
    avatar: "/imgs/club/member_avatar.png",
    vipLevel: "/imgs/club/vip.png",
    role: "normal",
  },
]);

const isShowWin = ref(false);
const club_title = ref('');
const club_tip = ref()
const memberIndex = ref(0)
const memberRole = ref('')
// 更新角色
// const updateRole = (index: number, role: "admin" | "normal", name: any) => {
//   club_tip.value =  role == 'admin' ? `是否将${name}设置为管理员` : `是否${name}将的管理员取消`
//   isShowWin.value = true;
//   memberIndex.value = index;
//   memberRole.value = role;
// };

const submitAc = () => {
  if (members[memberIndex.value].role === "creator") return; // 创建者无法更改角色
  members[memberIndex.value].role = memberRole.value;
  isShowWin.value = false
}

const close = () => {
  isShowWin.value = false
}


</script>

<style scoped lang="scss">
.content {
  font-size: 14px;
  margin: 0 0 10px;

  .arrow_left {
    width: 24px;
    height: 24px;
  }

  .save {
    height: 32px;
    line-height: 32px;
    text-align: center;
    color: #5BD9FF;
  }

}
.popup_body {
  color: #fff;
  padding: 10px;

  .info {
    margin-bottom: 10px;
    text-align: center;
    color: #FFFFFF;
    margin: 24px 0;
  }

  .submit_btn {
    margin: 20px 0;
    display: flex;
    justify-content: space-evenly;

    .submit_close {
      width: 147px;
      height: 42px;
      color: #FFFFFF;
      text-align: center;
      line-height: 44px;
      background: #282747;
      box-shadow: 0.5px 0.5px 1px 0px #2E296B inset;
      border-radius: 8px;
    }
  }
}
</style>
